<!DOCTYPE html>
<html>

<head>
    <title>北京站网格化系统</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Fonts -->
    <!-- CSS Libs -->
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap-switch.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/checkbox3.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/dataTables.bootstrap.css">
        <!-- <link rel="stylesheet" type="text/css" href="../lib/css/select.bootstrap.min.css"> -->
    <link rel="stylesheet" type="text/css" href="../lib/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/validform.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/js/jquery-treegrid-master/jquery.treegrid.css">
    <!-- CSS App -->
    <link rel="stylesheet" type="text/css" href="../lib/css/common/style.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/common/themes/flat-blue.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/common/newstyle.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/zc-common.css">
    <style>
    .usertable.loader:after {
        background-color: rgba(0, 0, 0, 0.2);
    }
    </style>
</head>
<body class="flat-blue">
    <div class="app-container expanded">
        <div class="row content-container">
            <nav class="navbar navbar-default navbar-fixed-top navbar-top">
                <div class="container-fluid app-header">
                    <div class="navbar-header">
                        <button type="button" class="navbar-expand-toggle fa-rotate-90">
                            <i class="fa fa-bars icon"></i>
                        </button>
                        <!-- 三级导航 -->
                        <top-nav></top-nav>
                    </div>
                    <right-info></right-info>
                </div>
            </nav>
            <div class="side-menu-wrap">
                <!-- 一二级导航 -->
                <side-menu></side-menu>
            </div>
            <!-- Main Content -->
            <div class="container-fluid">
                <div class="side-body padding-top">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="card card_list people-list">
                                <div class="elm-wrap">
                                    <button type="button" class="btn btn-info" onclick="editing()">添加员工</button>
                                    <button type="button" class="btn btn-default" onclick="importEx('people')">批量导入</button>
                                    <button type="button" class="btn btn-default deling" onclick="deling('more')">批量删除</button>
                                </div>
                                <div class="elm-wrap people-el">
                                    <div class="alert alert-info" role="alert">
                                            已选择 <span class="dtcount">0</span> 项  |   已删除的员工数据将无法恢复
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-4">
                                            <div class="row">
                                                <div class="col-sm-12">
                                                    <table id="tb" >
                                                            
                                                    </table> 
                                                </div>   
                                            </div>
                                        </div>
                                        <div class="col-sm-8">
                                            <div>
                                                <div class="card-body">
                                                    <table class="table table-striped usertable" cellspacing="0" width="100%">
                                                        <thead>
                                                            <tr>
                                                                <th class="select-checkbox datatable-checkall">
                                                                    
                                                                </th>
                                                                <th>员工工号</th>
                                                                <th>员工姓名</th>
                                                                <th>职务</th>
                                                                <th>级别</th>
                                                                <th>操作</th>
                                                            </tr>
                                                        </thead>
                                                        <tfoot>
                                                            <tr>
                                                                <th></th>
                                                                <th>员工工号</th>
                                                                <th>员工姓名</th>
                                                                <th>职务</th>
                                                                <th>级别</th>
                                                                <th>操作</th>
                                                            </tr>
                                                        </tfoot>
                                                        <tbody>
                                                                
                                                        </tbody>
                                                        
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                     
                                </div> 
                            </div>
                            <div class="card card_edit people-edit">
                                <div class="card-body">
                                <form class="form-horizontal ss_form">
                                    <div class="form-group">
                                        <label for="dep" class="col-sm-2 control-label">所属部门：</label>
                                        <div class="col-sm-10 col-md-6 col-lg-4">
                                            <!-- <input type="text" class="form-control" id="dep" placeholder="所属部门"> -->
                                            <p class="form-control-static depname">北京铁路局北京火车站</p>
                                            <input id="depid" name="depid" type="hidden" value="" datatype="ztreegroup" errormsg="" nullmsg="至少需要选择一个部门">
                                            <div class="departSelect">
                                                <input type="text" class="form-control treegroup tagselect" id="dep" name="dep" placeholder="所属部门">
                                                <!-- <div class="form-control" id="treegroup"></div> -->
                                                <div id="groudtree" class="groudtree">
                                            
                                                </div>    
                                            </div>
                                        </div>
                                        <div class="col-sm-10 col-md-6 col-lg-4 validwarning"></div>
                                    </div>
                                    <div class="form-group">
                                        <label for="user_account" class="col-sm-2 control-label">工号： </label>
                                        <div class="col-sm-10 col-md-6 col-lg-4 user_account_static">
                                            <p class="form-control-static user_account"></p>
                                        </div>
                                        <div class="col-sm-10 col-md-6 col-lg-4 user_account_input">
                                            <input type="text" class="form-control user_account" id="user_account" name="user_account" placeholder="工号" datatype="n" errormsg="工号为数字" nullmsg="工号不能为空">
                                            <p class="form-control-static font-alert">添加成功后不可修改</p>
                                        </div>
                                        <div class="col-sm-10 col-md-6 col-lg-4 validwarning"></div>
                                        
                                    </div>
                                    <div class="form-group">
                                        <label for="user_status" class="col-sm-2 control-label">当前状态： </label>
                                        <div class="col-sm-10 col-md-6 col-lg-4">
                                            <select class="form-control user_status" name="user_status" id="user_status" placeholder="请选择状态">
                                                <option value="1">正常</option>
                                                <option value="2">封停</option>
                                            </select> 
                                        </div>
                                    </div>
                                    <div class="form-group dropdown">
                                        <label for="user_name" class="col-sm-2 control-label">姓名： </label>
                                        <div class="col-sm-10 col-md-6 col-lg-4">
                                            <input type="text" class="form-control" id="user_name" placeholder="姓名" name="user_name" datatype="*" errormsg="姓名格式错误" nullmsg="姓名不能为空">
                                        </div>
                                        <div class="col-sm-10 col-md-6 col-lg-4 validwarning"></div>
                                    </div>
                                    <div class="form-group">
                                        <label for="user_job" class="col-sm-2 control-label">职务： </label>
                                        <div class="col-sm-10 col-md-6 col-lg-4">
                                            <input type="text" class="form-control" id="user_job" placeholder="请输入职务名称" datatype="*" errormsg="职务格式错误" nullmsg="职务不能为空" name="user_job">
                                        </div>
                                        <div class="col-sm-10 col-md-6 col-lg-4 validwarning"></div>
                                    </div>
                                    <div class="form-group dropdown">
                                        <label for="user_role" class="col-sm-2 control-label">角色： </label>
                                        <div class="col-sm-10 col-md-6 col-lg-4">
                                            <select class="form-control form-select user_role select-role" name="user_role" id="user_role" aria-placeholder="请选择角色" style="width:100%" datatype="select2" errormsg="" nullmsg="至少需要选择一个角色">
                                            </select> 
                                        </div>
                                        <div class="col-sm-10 col-md-6 col-lg-4 validwarning"></div>
                                    </div>
                                    <div class="form-group">
                                        <label for="user_level" class="col-sm-2 control-label">级别： </label>
                                        <div class="col-sm-10 col-md-6 col-lg-4">
                                            <select class="form-control user_level" name="user_level" id="user_level" placeholder="请选择级别">
                                                <option value="1">职工</option>
                                                <option value="2">干部</option>
                                            </select> 
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-offset-2 col-sm-10">
                                            <button type="button" class="btn btn-info edit-staff">添加员工</button>
                                            <button type="button" class="btn btn-default edit-cancel">取消</button>
                                        </div>
                                    </div>
                                </form>
                                </div>
                            </div>
                            <div class="card card_error">
                                <div class="elm-wrap">
                                    <button type="button" class="btn btn-info" onclick="importEx('people')">重新导入</button>
                                    <button type="button" class="btn btn-default" onclick="importExCancel()">取消导入</button>
                                </div>
                                <div class="elm-wrap">
                                    <table class="table table-bordered errortable">
                                        <thead>
                                          <tr>  
                                            <th width="130">行数（不算标题）</th>
                                            <th>错误原因</th>
                                          </tr> 
                                        </thead>
                                        <tbody class="tbody">
                                          <tr>  
                                            <td>1</td>
                                            <td>
                                              数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对数据不对
                                            </td>
                                          </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div> 
                        </div>   
                    </div>
                </div>
            </div>
        </div>
        <footer class="app-footer">
            <div class="wrapper"></div>
        </footer>
    </div>
    <div class="modal fade" id="modalimport" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">导入</h4>
                </div>
                <div class="modal-body">
                    <div class="" style="padding:5px;">
                        <form class="form-horizontal importexform" id="importexform" method="post" action="" enctype="multipart/form-data">
                                <div class="form-group">
                                    <label for="" class="col-sm-2 control-label">上传模版：</label>
                                    <div class="col-sm-10">
                                        <a href="" class="import-excel" target="_self">下载导入模版</a>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="" class="col-sm-2 control-label">上传文件：</label>
                                    <div class="col-sm-10">
                                        <input type="file" id="exampleInputFile" name="fileToUpload">
                                        <p class="help-block">请下载该模版，并严格遵循该模版规范录入数据。</p>
                                    </div>
                                </div>
                            </form>
                    </div>    
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-info importbtn">确定</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="modalDel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">删除人员</h4>
                </div>
                <div class="modal-body">
                    确定删除人员？
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default cancel" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-info deling">确认</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="modalTips" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel3">提示</h4>
                </div>
                <div class="modal-body">
                    温馨提示
                </div>
            </div>
        </div>
    </div>
<!-- Javascript Libs -->
<script type="text/javascript" src="../lib/js/jquery.min.js"></script>
<script type="text/javascript" src="../lib/js/common/base.js"></script>
<script type="text/javascript" src="../lib/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../lib/js/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.matchHeight-min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../lib/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../lib/js/select2.full.min.js"></script>
<script type="text/javascript" src="../lib/js/validform.js"></script>
<script type="text/javascript" src="../lib/js/dataTables.select.min.js"></script>
<script type="text/javascript" src="../lib/js/jquery-treegrid-master/jquery.treegrid.min.js"></script>
<script type="text/javascript" src="../lib/js/jquery-treegrid-master/jquery.treegrid.bootstrap3.js"></script>
<script type="text/javascript" src="../lib/js/jquery-treegrid-master/jquery.treegrid.extension.js"></script>
<script type="text/javascript" src="../lib/js/depchoice/edep_plugin.js"></script>
<script type="text/javascript" src="../lib/js/ztreeJs.js"></script>
<!-- <script type="text/javascript" src="../lib/js/ace/ace.js"></script> -->
<!-- <script type="text/javascript" src="../lib/js/ace/mode-html.js"></script> -->
<!-- <script type="text/javascript" src="../lib/js/ace/theme-github.js"></script> -->
<script src="../lib/js/vue.js"></script>
<!-- Javascript -->
<script type="text/javascript" src="../lib/js/common/app.js"></script>

<script>
    navData.accNav1 = 'organization'
    navData.nav1Name = '组织管理'
    navData.accNav2 = 'organization-people'
    navData.accNav3 = '4'
    var navVue = new Vue({
        el:'.side-menu-wrap' 
    })
    var navTopVue = new Vue({
        el:'.app-header' 
    })
    var importUrl = {
        file:serverUrl.base+'download/personnel.xls',
        url:serverUrl.base+serverUrl.importbatch+'DeptImportSave'
    }
    $('.import-excel').attr('href',importUrl.file)
    $('.importexform').attr('action',importUrl.url)
    var InfoDefault = {
        department_id:'',
        department_name:"",
        role_id:"",
        role_name:"",
        user_account:"",
        user_id:"",
        user_job:"",
        user_level:"",
        user_name:"",
        user_status:""
    }
    var Info={}
    //翻页条件
    var _upData={
        'page':1,
        'count':10,
        'department_id':''
    }
    var _dataTable = $('.usertable').DataTable({
        "dom": '<"top"fl<"clear">>rt<"bottom"ip<"clear">>',
        language:{
            url: '../lib/js/cn_lang.json'
        },
        serverSide:true,
        ajax:function(data,callback,settings){
            //console.log('data',data)
            $('.usertable').loading('open','加载中。。。')
            console.log(data)
            _upData.page = (data.start / data.length)+1;//当前页码
            _upData.count = data.length;//每页个数
            _upData.w = data.search.value;//搜索
            $.ajax({
                url:serverUrl.base+serverUrl.user+'user_list',
                type:"POST",
                data:_upData,
                cache: false,
                dataType:"json",
                success:function(res){
                    res.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                    res.recordsTotal = res.total;//返回数据全部记录
                    res.recordsFiltered = res.total;//后台不实现过滤功能，每次查询均视作全部结果
                    callback(res)
                    // if(res.code == 0){
                    //     // $('.tablepagewrap').html(res.result_page)
                    //     //console.log(res)
                    //     callback(res)
                    // }else{
                    //     callback(res)  
                    // }
                    // // callback(res)    
                },
                complete:function(res){
                    $('body').loading('close')
                    $('.usertable').loading('close')
                },
                error:function(res){
                    
                }    
            })
        },
        // ajax:{
        //     url:serverUrl.base+serverUrl.user+'user_list',
        //     data:{_:Math.random()},
        //     type:'POST',
        //     complete:function(){
        //         $('body').loading('close')
        //     }
        // },
        select:'multi',
        ordering:false,
        buttons:['colvis','excel', 'print','selectAll'],
        columns:[
            {"data":null,defaultContent:'',className: 'select-checkbox'},
            { "data": "user_account" },
            { "data": "user_name" },
            { "data": "user_job" },
            { "data": "user_level",render:function(data, type, row, meta){
                if(data == null || data == 1){
                    return '职工'
                }else if(data == 2){
                    return '干部'
                }
            }},{
                "data":null,render:function(data, type, row, meta){
                    //console.log()
                    return "<a onclick='editing(this)' href='javascript:void(0)'>编辑</a> <a onclick='deling(this)' href='javascript:void(0)'>删除</a>"
                },defaultContent:''
            }
            
        ]  
    })
    _dataTable.on('select.dt',function(){
        var selected = _dataTable.rows( { selected: true } ).count()
        $('.dtcount').text(selected)
    })
    _dataTable.on('deselect.dt',function(){
        var selected = _dataTable.rows( { selected: true } ).count()
        $('.dtcount').text(selected)
    })
    $('.datatable-checkall').click(function(){
        $(this).toggleClass('selected')
        if($(this).hasClass('selected')){
            _dataTable.rows().select()
        }else{
            _dataTable.rows().deselect()
        }
        
    })
    $('#tb').treegridData({
        id: 'department_id',
        parentColumn: 'p_id',
        textColumn:'department_name',
        type: "POST", //请求数据的ajax类型
        url: serverUrl.base+serverUrl.department+'department_list',   //请求数据的ajax的urlhttp://119.23.232.192:8081/Organization/../lib/json/base2.json
        ajaxParams: {_:Math.random()}, //请求数据的ajax的data属性
        expandColumn: null,//在哪一列上面显示展开按钮
        striped: false,   //是否各行渐变色
        bordered: false,  //是否显示边框
        expandAll: false,  //是否全部展开
        columns: [                            
            {
                title: '机构名称',
                field: 'department_name'
            }
        ],
        onclickNode:function(el){
            el.addClass('active')
            el.siblings('tr').removeClass('active')
            var _dep = el.treegridData('getNodeData'),_depId=_dep.department_id
            
           // _dataTable.settings()[0].ajax.data={'department_id':_depId}
            _upData.department_id = _depId
            //console.log(_dataTable.ajax.data)
            _dataTable.ajax.reload()
            $('.dtcount').text(0)
            //console.log(_dep)
            var _info = {
                department_id: _depId,
                department_name: _dep.department_name
            }
            Info = $.extend({},InfoDefault,_info)
        }
    });

    function deling(e){
        if(e != 'more'){
            var _data = [_dataTable.row($(e).parents('tr')).data()]      
        }else{
            var _data = _dataTable.rows( { selected: true }).data()
        } 
        var _upD = []
        for(var i =0;i< _data.length;i++){
            _upD.push(_data[i].user_id)
        }
        _upD = _upD.join(',')

        $('#modalDel').modal() 
        $('#modalDel').find('.deling').off('click').on('click',function(){
            $('.people-list').loading('open')
            $.ajax({
                url:serverUrl.base+serverUrl.user+'del_user',
                type:"POST",
                data:{"user_id":_upD},
                dataType:"json",
                success:function(res){
                    if(res.code == 0){
                        if(e != 'more'){
                            _dataTable.row($(e).parents('tr')).remove().draw(false)
                        }else{
                            _dataTable.rows( { selected: true }).remove().draw(false)
                        }
                        $("#modalTips").find('.modal-title').text('成功')   
                        $("#modalTips").find('.modal-body').text('员工删除成功！')
                    }else if(res.code == '2'){
                        $("#modalTips").find('.modal-title').text('出现问题') 
                        $("#modalTips").find('.modal-body').text(res.info)
                    }
                    setTimeout(function(){
                        $("#modalTips").modal()    
                    },500)

                },
                complete:function(res){
                    $('#modalDel').modal('hide')
                    $('.people-list').loading('close')
                },
                error:function(res){
                    $("#modalTips").find('.modal-title').text('出现问题') 
                    $("#modalTips").find('.modal-body').text(res.info)
                    setTimeout(function(){
                        $("#modalTips").modal()    
                    },500)
                }    
            })
        })

        $('#modalDel').find('.cancel').off('click').on('click',function(){
            _dataTable.row($(e).parents('tr')).deselect()
        })
    }
    function editing(e){
        $('.people-edit').show()
        $('.people-list').hide()
        var _data={}
        if(e){
            _data = _dataTable.row($(e).parents('tr')).data()
            Info = $.extend({},InfoDefault,_data)
            Info.row = _dataTable.row($(e).parents('tr'))

            $('.user_account_static').show().siblings('.user_account_input').hide()
            $('p.user_account').text(Info.user_account)
            $('.edit-staff').text('保存')
        }else{
            Info = $.extend({},InfoDefault,Info)

            $('.user_account_input').show().siblings('.user_account_static').hide()
            $('.edit-staff').text('添加')  
        }
        $('input[name=depid]').val(Info.department_id)
        $('input[name=user_account]').val(Info.user_account)
        $('input[name=user_name]').val(Info.user_name)
        $('input[name=user_job]').val(Info.user_job)
        $('select[name=user_level]').val(Info.user_level != ''?Info.user_level:"1")
        $('select[name=user_status]').val(Info.user_status != ''?Info.user_status:"1")
        $('select.select-role').val(Info.has_role).trigger('change')
        if(Info.department_id == '' || Info.row){
            $('.departSelect').show().siblings('.depname').hide()
            $('input[name=dep]').val(Info.department_name)
            
        }else{
            $('.depname').show().text(Info.department_name).siblings('.departSelect').hide()
        }
        
    }
    
    // 
    $('.edit-staff').on('click',function(){
        if(!myValidform.check()){
            return false
        }
        var _roleIdData=$('select.select-role').select2("data"),_roleId=[]
        for(var i=0;i<_roleIdData.length;i++){
            _roleId.push(_roleIdData[i].id)
        }
        var upData={
            user_id:Info.user_id,
            user_name:$('input[name=user_name]').val(),
            user_account:$('input[name=user_account]').val(),
            user_job:$('input[name=user_job]').val(),
            user_level:$('select[name=user_level]').val(),
            has_role:_roleId,
            user_status:$('select[name=user_status]').val(),
            department_id:$('input[name=depid]').val()
        }
        $('.people-edit').loading('open')
        $.ajax({
            url:serverUrl.base+serverUrl.user+'edit_user',
            type:"POST",
            data:upData,
            dataType:"json",
            success:function(res){
                if(res.code == 0){
                    //更新表格
                    // _dataTable.settings()[0].ajax.data={'department_id':Info.department_id}
                    // _dataTable.ajax.reload()
                    if(Info.row){
                        Info.row.deselect();
                        _dataTable.ajax.reload(function(){},false)
                    }else{
                        _dataTable.ajax.reload()
                    }
                    
                    
                    Info = {}
                    $('.people-edit').hide()
                    $('.people-list').show()
                    $("#modalTips").find('.modal-title').text('成功') 
                    var _info=''
                    if($('.edit-staff').text() ==  '添加'){
                        _info = '员工添加成功！'
                    }else{
                        _info = '员工修改成功！'
                    }
                    $("#modalTips").find('.modal-body').text(_info)
                }else if(res.code == '2'){
                    $("#modalTips").find('.modal-title').text('出现问题') 
                    $("#modalTips").find('.modal-body').text(res.info)
                }
                setTimeout(function(){
                    $("#modalTips").modal()    
                },500)

            },
            complete:function(res){
                $('#modalDel').modal('hide')
                $('.people-edit').loading('close')
            },
            error:function(res){
                $("#modalTips").find('.modal-title').text('出现问题') 
                $("#modalTips").find('.modal-body').text(res.info)
                setTimeout(function(){
                    $("#modalTips").modal()    
                },500)
            }    
        })
    })
    $('.edit-cancel').on('click',function(){
        Info.row && Info.row.deselect()
        Info={}
        $('.card_edit').hide()
        $('.card_list').show()
    })
    function importExCancel(){
        $('.card_error').hide()
        $('.card_error').find('.errortable tbody tr').remove()
        $('.card_list').show()
    }        
    //批量导入
    function importEx(type){
        var $modal = $('#modalimport')
        $modal.find('#exampleInputFile').val('')
        var _txt = {
            tit:'批量导入'
        }
        switch(type){
            case 'people':
                _txt.tit = '批量导入人员'
            break;
        }
        $modal.find('.modal-title').text(_txt.tit) 
        $modal.modal()
        $('.importbtn').off('click').on('click',function(){
            
            var formDataPic = new FormData(document.getElementById('importexform'))
            console.log($('.importexform').val())
            var excel=['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/vnd.ms-excel']
            var fileType = String(document.getElementById('exampleInputFile').files[0].type)
            if(excel[0] == fileType || excel[1] == fileType){
                $modal.modal('hide')
                $('.card_list').loading('open')
                $.ajax({
                    url:importUrl.url,
                    type:"POST",
                    data:formDataPic,
                    cache: false,
                    contentType: false,  
                    processData: false,
                    beforeSend:function (returndata){
                        //dd.show()
                    },
                    dataType:"json",
                    success:function(res){
                        var _txt={
                            tit:'提交成功',
                            info:res.info
                        }
                        if(res.code == 0){
                            //更新表格
                            // _dataTable.settings()[0].ajax.data={'department_id':Info.department_id}
                            // _dataTable.ajax.reload()
                            
                            if(Info.row){
                                Info.row.deselect();
                                _dataTable.ajax.reload()
                            }else{
                                _dataTable.ajax.reload()
                            }
                            Info = {}
                            $('.card_edit').hide()
                            $('.card_list').show()
                        }else if(res.code == '1'){
                            // $('.card_error').show()
                            // $('.card_list').hide()
                            $('.card_edit').hide()
                            $('.card_list').show()
                            _txt.tit = '提交失败' 
                        }else{
                            _txt.tit = '提交失败'
                            _txt.info = '未知错误，请联系开发商'
                        }
                        setTimeout(function(){
                            $("#modalTips").find('.modal-title').text(_txt.tit) 
                            $("#modalTips").find('.modal-body').text(_txt.info)
                            $("#modalTips").modal()    
                        },500)

                    },
                    complete:function(res){
                        $('.card_list').loading('close')
                    },
                    error:function(res){
                        $("#modalTips").find('.modal-title').text('出现问题') 
                        $("#modalTips").find('.modal-body').text(res.info)
                        setTimeout(function(){
                            $("#modalTips").modal()    
                        },500)
                    }    
                })
            }else{
                // $("#modalTips").find('.modal-title').text('提交失败') 
                // $("#modalTips").find('.modal-body').text('您提交的文件格式不对')
                // $("#modalTips").modal() 
                $modal.find('#exampleInputFile').val('')
                alert('文件格式不对！')
            } 
        })           
    }
    
    // $('.select-role').select2({
    //     placeholder:'选择',
    //     data:datas,
    //     multiple: true
    // })
    // $('.select-role').val(['1', '2']).trigger('change');
    // $('.select-role')
    var myValidform = $(".ss_form").Validform({
        tiptype:2,
        datatype:{
            ztreegroup:function(gets,obj,curform,regxp){
                console.log(gets)
                if(gets == ''){
                    return false
                }else{
                }
            },
            select2:function(gets,obj,curform,regxp){
                if(gets.length ==0){
                    $('.select2-selection').css('borderColor','red')
                    return false
                }else{
                    $('.select2-selection').css('borderColor','#ccc')
                }
            }
        }
    });
    $('.treegroup').on('click',function(){
        showsDeptWin('dep','depid','3',myValidform);
    })
    var select = new rpSelect({
        sel:'select-role',
        url:serverUrl.base+serverUrl.user+'role_list',
        valide:myValidform
    })
</script>
</body>

</html>
